//split a string
vector<string> parse(string mystr){
    char *sentence = (char*)mystr.c_str(); // string to chat array
    char *word;
    static char delim[]=" ";
    vector<string> words;
    for(word=strtok(sentence,delim);word; word=strtok(0,delim)){
        if( strlen(word) )
            words.pb(word);
    }
    return words;
}

//replace a string "from" => "to"
inline string replaceAll(string str, string from, string to) {
    size_t start_pos = 0;
    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length();
    }
	return str;
}

inline int readword ( char *buffer ) {
    int c, cnt = 0;
    c = getchar();
    while ( c >= 0 && c <= ' ' ) {
        c = getchar();
    }
    if ( c < 0 ) {
        buffer[cnt] = 0;
        return cnt;
    }
    while ( c > ' ' ) {
        buffer[cnt++] = c;
        c = getchar();
    }
    buffer[cnt] = 0;
    return cnt;
}
struct mystr {
        char *buff;
        mystr() {
        }
        mystr(char *str) {
                this->buff = (char *) strdup(str);
        }
        bool operator<(const mystr &r) const {
                return strcmp(this->buff, r.buff) < 0 ? true : false;
        }
};